var testCaseSubtraction = new YAHOO.tool.TestCase({
  name: "Generation of subtraction problems",
  setUp : function () {
      this.simpleSubtractionOf7 = new ArithmeticProblemType(
        "SimpleSubtractionOf7",
        "Subtraction of 7 from minuends up to 10",
        1,
        [ null,{lb:7,ub:10},{lb:7,ub:7}],  // result number range enforces non-negative integers
        [ OperatorEL.minus],       // operators
        0       // askedFor = "result"
      );
      this.basicSubtraction = new ArithmeticProblemType(
          "subtraction",
          "subtraction",
          NumberTypeEL.NonNegativeInteger,
          [ {lb:0,ub:10},{lb:0,ub:10},{lb:0,ub:10}],  // result number range enforces non-negative integers
          [OperatorEL.minus],       // operators
          0       // askedFor = "result"
        );
      this.additionAndSubtraction = new ArithmeticProblemType(
            "addition and subtraction",
            "addition and subtraction",
            NumberTypeEL.NonNegativeInteger,
            [ {lb:0,ub:20},{lb:0,ub:10},{lb:0,ub:10},{lb:0,ub:10}], // result number range enforces non-negative integers
            [ OperatorEL.plus, OperatorEL.minus],      // operators
            0       // askedFor = "result"
        );
      this.doubleSubtraction = new ArithmeticProblemType(
          "DoubleSubtraction",
          "Two chained subtractions",
          1,
          [ {lb:0,ub:20},{lb:0,ub:20},{lb:1,ub:10},{lb:1,ub:10}], // result number range enforces non-negative integers
          [ OperatorEL.minus, OperatorEL.minus],      // operators
          0       // askedFor = "result"
        );
  },
  tearDown : function () {
      delete this.basicSubtraction;
      delete this.additionAndSubtraction;
      delete this.simpleSubtractionOf7;
      delete this.doubleSubtraction;
  },

  testSimpleSubtractionOf7: function () {
    var Assert = YAHOO.util.Assert;
    var ap1 = this.simpleSubtractionOf7.generateProblem();
    Assert.isTrue( ap1.type.numberRanges[1].lb <= ap1.operands[0] &&
      ap1.operands[0] <= ap1.type.numberRanges[1].ub, "First operand should be in second number range.");
    Assert.isTrue( ap1.type.numberRanges[2].lb <= ap1.operands[1] &&
      ap1.operands[1] <= ap1.type.numberRanges[2].ub, "Second operand should be in third number range.");
    Assert.areSame( ap1.result, ap1.operands[0] - ap1.operands[1]);
  },
  testBasicSubtraction: function () {
    var Assert = YAHOO.util.Assert;
    var ap1 = this.basicSubtraction.generateProblem();
    Assert.isTrue( ap1.type.numberRanges[0].lb <= ap1.result &&
      ap1.result <= ap1.type.numberRanges[0].ub, "Result value should be in number range.");
    Assert.isTrue( ap1.type.numberRanges[1].lb <= ap1.operands[0] &&
      ap1.operands[0] <= ap1.type.numberRanges[1].ub, "First operand should be in second number range.");
    Assert.isTrue( ap1.type.numberRanges[2].lb <= ap1.operands[1] &&
      ap1.operands[1] <= ap1.type.numberRanges[2].ub, "Second operand should be in third number range.");
    Assert.areSame( ap1.result, ap1.operands[0] - ap1.operands[1]);
  },
  testAdditionAndSubtraction: function () {
    var Assert = YAHOO.util.Assert;
    var ap1 = this.additionAndSubtraction.generateProblem();
    Assert.isTrue( ap1.type.numberRanges[0].lb <= ap1.result &&
      ap1.result <= ap1.type.numberRanges[0].ub, "Result value should be in number range.");
    Assert.isTrue( ap1.type.numberRanges[1].lb <= ap1.operands[0] &&
      ap1.operands[0] <= ap1.type.numberRanges[1].ub, "First operand should be in second number range.");
    Assert.isTrue( ap1.type.numberRanges[2].lb <= ap1.operands[1] &&
      ap1.operands[1] <= ap1.type.numberRanges[2].ub, "Second operand should be in third number range.");
    Assert.isTrue( ap1.type.numberRanges[3].lb <= ap1.operands[2] &&
      ap1.operands[2] <= ap1.type.numberRanges[3].ub, "Third operand should be in fourth number range.");
    Assert.areSame( ap1.result, ap1.operands[0] + ap1.operands[1] - ap1.operands[2]);
  },
  testDoubleSubtraction: function () {
    var Assert = YAHOO.util.Assert;
    var ap1 = this.doubleSubtraction.generateProblem();
    Assert.isTrue( ap1.type.numberRanges[0].lb <= ap1.result &&
      ap1.result <= ap1.type.numberRanges[0].ub, "Result should be in first number range.");
    Assert.isTrue( ap1.type.numberRanges[1].lb <= ap1.operands[0] &&
      ap1.operands[0] <= ap1.type.numberRanges[1].ub, "First operand should be in second number range.");
    Assert.isTrue( ap1.type.numberRanges[2].lb <= ap1.operands[1] &&
      ap1.operands[1] <= ap1.type.numberRanges[2].ub, "Second operand should be in third number range.");
    Assert.isTrue( ap1.type.numberRanges[3].lb <= ap1.operands[2] &&
      ap1.operands[2] <= ap1.type.numberRanges[3].ub, "Third operand should be in fourth number range.");
    Assert.areSame( ap1.result, ap1.operands[0] - ap1.operands[1] - ap1.operands[2]);
  }
});
